<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<title>Syntax of constants and variables</title>
	</head>
	<body>
		<h1>Syntax of constants and variables</h1>

		<a id="Boolean"/><h2>Boolean</h2>
		<p>Constants true and false are the two only instances of class Boolean.</p>

		<a id="Nil"/><h2>Nil</h2>
		<p>Constant nil is the single instance of class Nil.</p>

		<a id="String"/><h2>String and Char</h2>
		<p>
		A string constant is defined by a sequence of characters from the extended ASCII set of 256 characters enclosed by double quotation marks. Special syntax is added to represent non-printable characters by means of <i>escape sequences</i> that all begin with the backslash (\) symbol. Characters with ASCII value below 32 (except ASCII value 9) and the two characters " (double quotation mark, ASCII value 34) and \ (backslash, ASCII value 92) are not allowed in a string constant except as part of an escape sequence. The escape sequences that are supported are conforming to the C / Java specifications and provided in the table below.
		</p>
		<p>
		Similarly, character constants are represented by a character between single quotation marks for characters with ASCII values 9 and 32 and above, except the single quotation mark character (ASCII value 39) and the backslash character (ASCII value 92). Moreover, any escape sequence can be used (between single quotation marks).
		</p>
		<table>
			<tr><th>Character</th><th>ASCII Representation</th><th>ASCII Value</th><th>Escape Sequence</th></tr>
			<tr><td>Newline</td><td>NL (LF)</td><td>10</td><td>\n</td></tr>
			<tr><td>Horizontal tab</td><td>HT</td><td>9</td><td>\t</td></tr>
			<tr><td>Vertical tab</td><td>VT</td><td>11</td><td>\v</td></tr>
			<tr><td>Backspace</td><td>BS</td><td>8</td><td>\b</td></tr>
			<tr><td>Carriage return</td><td>CR</td><td>13</td><td>\r</td></tr>
			<tr><td>Formfeed</td><td>FF</td><td>12</td><td>\f</td></tr>
			<tr><td>Alert</td><td>BEL</td><td>7</td><td>\a</td></tr>
			<tr><td>Backslash</td><td>\</td><td>92</td><td>\\</td></tr>
			<tr><td>Question mark</td><td>?</td><td>63</td><td>\?</td></tr>
			<tr><td>Single quotation mark</td><td>'</td><td>39</td><td>\'</td></tr>
			<tr><td>Double quotation mark</td><td>"</td><td>34</td><td>\"</td></tr>
			<tr><td>Hexadecimal number</td><td><i>hh</i></td><td>any</td><td>\x<i>hh</i></td></tr>
		</table>
		<p>
		The escape sequence using hexadecimal number representation can have 1 or 2 hexadecimal digits. The hexadecimal value should be different from 0, but it is allowed to have a 0 as a first of two digits.
		In addition characters '\x0' and '\x00' are allowed, but these escape sequences cannot be used inside strings.
		The <a href="BasicClasses.html">documentation of the basic classes</a> refers to the following classes of special characters and character sequences:
		<ul>
		<li>White space characters are: Space(32), TAB(9), CR (13), LF(10), VT(11), FF(12)
		<li>New line character sequences are: CR (13), LF(10), and CR(13) followed by LF(10)
		</ul>
		</p>
		<p>
		Syntactic representations of String constants are not unique. Whenever a syntactic representation of a String constant is generated, the following encoding shall be used. For any character which has an individual encoding shown in the above table, this encoding shall be used. For any other character with an ASCII value below 32 (except ASCII value 9) the hexadecimal number escape sequence shall be used. All other characters are not encoded.
		</p>

		<a id="Integer"/><h2>Integer and Real</h2>
		<p>
		Integer and real constants can be expressed in the following syntax:
		<table>
		<tr><td>&lt;Integer&gt;</td><td>::=</td><td>	["-"|"+"] &lt;Digits&gt; [("e"|"E") ["+"] &lt;DecimalDigit&gt;*]</td></tr>
		<tr><td></td><td></td><td>						| ["-"|"+"] "0" ["b"|"B"] &lt;BinaryDigit&gt;+</td></tr>
		<tr><td></td><td></td><td>						| ["-"|"+"] "0" ["x"|"X"]&lt;HexadecimalDigit&gt;+</td></tr>
		<tr><td>&lt;Real&gt;</td><td>::=</td><td>		["-"|"+"] (&lt;Digits&gt; "." &lt;DecimalDigit&gt;* |  "."  &lt;DecimalDigit&gt;+) [("e"|"E") ["-"|"+"] &lt;DecimalDigit&gt;*]</td></tr>
		</table>
		</p>
		<p>
		These definitions are based on the following definitions:
		<table>
		<tr><td>&lt;BinaryDigit&gt;			</td><td>::=</td><td>	"0" | "1"</td></tr>
		<tr><td>&lt;DecimalDigit&gt;		</td><td>::=</td><td>	"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"</td></tr>
		<tr><td>&lt;HexadecimalDigit&gt;	</td><td>::=</td><td>	"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"</td></tr>
		<tr><td>&lt;NonZeroDecimalDigit&gt;	</td><td>::=</td><td>	"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"</td></tr>
		<tr><td>&lt;Digits&gt;				</td><td>::=</td><td>	&lt;DecimalDigit&gt; | &lt;NonZeroDecimalDigit&gt; &lt;DecimalDigit&gt;+</td></tr>
		</table>
		</p>

		<a id="Variable"/><h2>Variable</h2>
		<p>Identifiers (variables, etc.) can be expressed in the following syntax:
		<table>
		<tr><td>&lt;Identifier&gt;</td><td>::=</td><td>	(LowerCaseLetter | UpperCaseLetter) (LowerCaseLetter | UpperCaseLetter | DecimalDigit | "_")*</td></tr>
		</table>
		</p>
		<p>
		This definition is based on the following definitions:
		<table>
		<tr><td>&lt;LowerCaseLetter&gt;</td><td>::=</td><td>	"a" | ... | "z"</td></tr>
		<tr><td>&lt;UpperCaseLetter&gt;</td><td>::=</td><td>	"A" | ... | "Z"</td></tr>
		<tr><td>&lt;DecimalDigit&gt;   </td><td>::=</td><td>	"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"</td></tr>
		</table>
		</p>

		<a id="Environment"/><h2>Environment variable</h2>
		<p>
		An environment variable is defined by a non-empty sequence of characters (alphabetical, numerical and underscore) , enclosed by the character sequence "${" and "}".
		When starting a simulation, each environment variable is replaced by its value.
		This requires that the environment variable is set in the operating system, and that its value can be parsed as another POOSL constant.
		</p>
	</body>
</html>